-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
General
: Warn users again before reloading certain pages with unsaved changes
#10193
General
: Warn users again before reloading certain pages with unsaved changes
#10193
Conversation
WalkthroughThe pull request introduces new functionality across several components by adding Changes
Assessment against linked issues
Possibly related PRs
Suggested Labels
Suggested Reviewers
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/main/webapp/app/exam/participate/exam-participation.component.ts
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/webapp/app/exam/participate/exam-participation.component.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: client-tests
- GitHub Check: server-tests
- GitHub Check: Build and Push Docker Image
- GitHub Check: Analyse
🔇 Additional comments (1)
src/main/webapp/app/exam/participate/exam-participation.component.ts (1)
1-1
: LGTM!The
HostListener
import is correctly added to the existing@angular/core
imports.
src/main/webapp/app/exam/participate/exam-participation.component.ts
Outdated
Show resolved
Hide resolved
…tom message when reloading
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on TS4, works as expected
There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer @HostListener('window:beforeunload', ['$event'])
because window:beforeunload
is deprecated, also see my inline comment
apparently there is no alternative solution, so we will keep using the deprecated version
c1bc701
Exam mode
: Warn user before reloading the pageGeneral
: Warn users again before reloading certain pages with unsaved changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/main/webapp/app/exercises/programming/shared/code-editor/container/code-editor-container.component.ts (1)
308-310
: Consider enhancing the deactivation check.The
canDeactivate()
method could be more robust by also checking theisLoading
state to prevent navigation during file operations.- canDeactivate() { - return _isEmpty(this.unsavedFiles); - } + canDeactivate() { + return !this.isLoading && _isEmpty(this.unsavedFiles); + }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
src/main/webapp/app/admin/standardized-competencies/standardized-competency-management.component.ts
(2 hunks)src/main/webapp/app/course/competencies/generate-competencies/generate-competencies.component.ts
(2 hunks)src/main/webapp/app/course/competencies/import-standardized-competencies/course-import-standardized-course-competencies.component.ts
(2 hunks)src/main/webapp/app/course/competencies/import/import-course-competencies.component.ts
(2 hunks)src/main/webapp/app/exam/participate/exam-participation.component.ts
(2 hunks)src/main/webapp/app/exercises/modeling/participate/modeling-submission.component.ts
(4 hunks)src/main/webapp/app/exercises/programming/shared/code-editor/container/code-editor-container.component.ts
(4 hunks)src/main/webapp/app/exercises/quiz/manage/quiz-exercise-update.component.ts
(2 hunks)src/main/webapp/app/exercises/text/participate/text-editor.component.ts
(4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/webapp/app/exam/participate/exam-participation.component.ts
🧰 Additional context used
📓 Path-based instructions (1)
`src/main/webapp/**/*.ts`: angular_style:https://angular.io/...
src/main/webapp/app/course/competencies/generate-competencies/generate-competencies.component.ts
src/main/webapp/app/course/competencies/import/import-course-competencies.component.ts
src/main/webapp/app/admin/standardized-competencies/standardized-competency-management.component.ts
src/main/webapp/app/exercises/quiz/manage/quiz-exercise-update.component.ts
src/main/webapp/app/exercises/modeling/participate/modeling-submission.component.ts
src/main/webapp/app/course/competencies/import-standardized-competencies/course-import-standardized-course-competencies.component.ts
src/main/webapp/app/exercises/text/participate/text-editor.component.ts
src/main/webapp/app/exercises/programming/shared/code-editor/container/code-editor-container.component.ts
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: validate-pr-title
- GitHub Check: Call Build Workflow / Build .war artifact
- GitHub Check: Call Build Workflow / Build and Push Docker Image
- GitHub Check: server-style
- GitHub Check: client-tests-selected
- GitHub Check: client-tests
- GitHub Check: server-tests
- GitHub Check: Analyse
🔇 Additional comments (8)
src/main/webapp/app/course/competencies/import/import-course-competencies.component.ts (1)
210-222
: LGTM! Clean implementation of page reload warning.The implementation correctly handles the beforeunload event and follows best practices:
- Proper event prevention when there are unsaved changes
- Reuse of existing
canDeactivate()
method- Localized warning message
src/main/webapp/app/course/competencies/import-standardized-competencies/course-import-standardized-course-competencies.component.ts (1)
182-194
: LGTM! Consistent implementation of reload warning.The implementation follows the established pattern and best practices:
- Proper event handling
- Reuse of
canDeactivate()
method- Consistent warning message
src/main/webapp/app/course/competencies/generate-competencies/generate-competencies.component.ts (1)
250-262
: LGTM! Well-implemented reload warning.The implementation maintains consistency with other components:
- Proper event handling
- Reuse of
canDeactivate()
method- Consistent warning message
src/main/webapp/app/exercises/programming/shared/code-editor/container/code-editor-container.component.ts (1)
317-324
: LGTM! Well-implemented reload warning.The implementation follows the established pattern and best practices:
- Proper event handling
- Reuse of
canDeactivate()
method- Consistent warning message
src/main/webapp/app/exercises/text/participate/text-editor.component.ts (1)
381-393
: LGTM! Well-implemented unload notification.The implementation follows Angular best practices and correctly handles the beforeunload event to prevent accidental data loss.
src/main/webapp/app/exercises/quiz/manage/quiz-exercise-update.component.ts (1)
378-390
: LGTM! Consistent implementation of unload notification.The implementation matches the pattern used in other components and correctly handles unsaved changes.
src/main/webapp/app/admin/standardized-competencies/standardized-competency-management.component.ts (1)
599-611
: LGTM! Good use of getter for warning message.The implementation follows the same pattern as other components while nicely encapsulating the warning message in a getter.
src/main/webapp/app/exercises/modeling/participate/modeling-submission.component.ts (1)
834-846
: LGTM! Consistent implementation of unload notification.The implementation follows the established pattern and correctly handles unsaved changes in the modeling submission.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently, window:beforeunload
is the only working option at the moment. Even though it is discouraged to use it, there is no viable solution to prevent accidental page reloads with unsaved changes. Therefore, I added it back to all places, that previously removed it (see #9479)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also tested:
Locally - competencies
On TS5 - exam participation, modeling participation, code editor, quiz update, text editor
Everything works as expected and a warning is displayed both for navigation and reload
Checklist
General
Client
authorities
to all new routes and checked the course groups for displaying navigation elements (links, buttons).Motivation and Context
Fixes #10142
Exam Mode Testing
Prerequisites:
Testserver States
Note
These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.
Review Progress
Performance Review
Code Review
Manual Tests
Exam Mode Test
Performance Tests
Test Coverage
Screenshots
Summary by CodeRabbit